docChanges(docChanges: CodeMirror.EditorChange[]) { if (this._recreateTimeout)
clearTimeout(this._recreateTimeout);
this._recreateTimeout = setTimeout(() => this._recreateLines(), 200);
scroll(scrollInfo: CodeMirror.ScrollInfo) { var height = scrollInfo.height;
var lineCount = this._doc.lineCount();
if (lineCount < this._viewLineNumber)
height = Math.max(height, this._doc.getEditor().defaultTextHeight() * this._viewLineNumber);
this.viewportFrom((scrollInfo.top * 100 / height) + '%');
this.viewportHeight((scrollInfo.clientHeight * 100 / height) + '%');
(<any>scrollInfo).maxHeight = height;
heightAtLine: this._doc.getEditor().heightAtLine(lineCount - 2),
defaultLineHeight: this._doc.getEditor().defaultTextHeight(),
bindHandlers(dragElement: HTMLElement) { addEventListener(dragElement, 'touchstart', (e: any) => { if (!e.touches || !e.touches.length) return;
var editor = this._doc.getEditor();
var scrollInfo = editor.getScrollInfo();
if (scrollInfo.clientHeight === scrollInfo.height) return;
var startTop = scrollInfo.top;
var startCoord = e.touches[0].clientY;
var factor = scrollInfo.clientHeight / scrollInfo.height;
if (!e.touches || !e.touches.length) return;
var editor = this._doc.getEditor();
var scrollInfo = editor.getScrollInfo();
var deltaY = e.touches[0].clientY - startCoord;
var offset = deltaY * factor;
editor.scrollTo(null, scrollInfo.top + deltaY);
dbg = 'scrollY->'+ (scrollInfo.top + deltaY)+' factor:'+factor+' deltaY:'+deltaY;
removeEventListener(window, 'touchend', close);
removeEventListener(window, 'touchmove', move);
addEventListener(window, 'touchmove', move);
addEventListener(window, 'touchend', close);
addEventListener(dragElement, 'mousedown', (e: MouseEvent) => { var editor = this._doc.getEditor();
var scrollInfo = editor.getScrollInfo();
if (scrollInfo.clientHeight === scrollInfo.height) return;
var startTop = scrollInfo.top;
var startCoord = e.clientY;
var factor = scrollInfo.clientHeight / scrollInfo.height;
var move = (e: MouseEvent) => { var editor = this._doc.getEditor();
var scrollInfo = editor.getScrollInfo();
var deltaY = e.clientY - startCoord;
var offset = deltaY * factor;
editor.scrollTo(null, scrollInfo.top + deltaY);
dbg = 'scrollY->' + (scrollInfo.top + deltaY) + ' factor:' + factor + ' deltaY:' + deltaY;
removeEventListener(window, 'mouseup', close);
removeEventListener(window, 'mousemove', move);
addEventListener(window, 'mousemove', move);
addEventListener(window, 'mouseup', close);
private _recreateLines() { var newLines: ScrollerModel.LineModel[] = [];
var docLineCount = this._doc.lineCount();
var maxLinesPerRun = (docLineCount / this._viewLineNumber) | 0;
for (var i = 0; i < docLineCount; i++) { run[runLength] = this._doc.getLine(i);
if (runLength >= maxLinesPerRun || i === docLineCount - 1) { if (run.length > runLength)
var newLine = this._createLine(run);
maxLength = Math.max(maxLength, newLine.leadLength + newLine.textLength);
for (var i = 0; i < newLines.length; i++) {